home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / clib / sys / h / wait < prev   
Text File  |  1996-11-09  |  3KB  |  102 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/sys/h/RCS/wait,v $
  4.  * $Date: 1996/10/30 22:04:51 $
  5.  * $Revision: 1.2 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: wait,v $
  10.  * Revision 1.2  1996/10/30 22:04:51  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.1  1996/05/06 09:03:13  unixlib
  14.  * Initial revision
  15.  *
  16.  ***************************************************************************/
  17.  
  18. /* POSIX Standard 3.2.1: Wait for Process Termination <sys/wait.h>.  */
  19.  
  20. #ifndef    __SYS_WAIT_H
  21.  
  22. #define    __SYS_WAIT_H 1
  23.  
  24. #ifndef __UNIXLIB_TYPES_H
  25. #include <unixlib/types.h>
  26. #endif
  27. #ifndef __SYS_RESOURCE_H
  28. #include <sys/resource.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. /* Bits in the third arguent to waitpid.  */
  36. #define WNOHANG 1 /* Don't block waiting.  */
  37. #define WUNTRACED 2 /* Report status of stopped children.  */
  38.  
  39. /* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
  40. #define    __WEXITSTATUS(status)    (((status) & 0xff00) >> 8)
  41.  
  42. /* If WIFSIGNALED(STATUS), the terminating signal.  */
  43. #define    __WTERMSIG(status)    ((status) & 0x7f)
  44.  
  45. /* If WIFSTOPPED(STATUS), the signal that stopped the child.  */
  46. #define    __WSTOPSIG(status)    __WEXITSTATUS(status)
  47.  
  48. /* Nonzero if STATUS indicates normal termination.  */
  49. #define    __WIFEXITED(status)    (__WTERMSIG(status) == 0)
  50.  
  51. /* Nonzero if STATUS indicates termination by a signal.  */
  52. #define    __WIFSIGNALED(status)    (!__WIFSTOPPED(status) && !__WIFEXITED(status))
  53.  
  54. /* Nonzero if STATUS indicates the child is stopped.  */
  55. #define    __WIFSTOPPED(status)    (((status) & 0xff) == 0x7f)
  56.  
  57. /* Nonzero if STATUS indicates the child dumped core.  */
  58. #define    __WCOREDUMP(status)    ((status) & __WCOREFLAG)
  59.  
  60. /* Macros for constructing status values.  */
  61. #define    __W_EXITCODE(ret, sig)    ((ret) << 8 | (sig))
  62. #define    __W_STOPCODE(sig)    ((sig) << 8 | 0x7f)
  63. #define    __WCOREFLAG        0x80
  64.  
  65.  
  66. #define    WEXITSTATUS(status)    __WEXITSTATUS(status)
  67. #define    WTERMSIG(status)    __WTERMSIG(status)
  68. #define    WSTOPSIG(status)    __WSTOPSIG(status)
  69. #define    WIFEXITED(status)    __WIFEXITED(status)
  70. #define    WIFSIGNALED(status)    __WIFSIGNALED(status)
  71. #define    WIFSTOPPED(status)    __WIFSTOPPED(status)
  72.  
  73. #define    WCOREFLAG        __WCOREFLAG
  74. #define    WCOREDUMP(status)    __WCOREDUMP(status)
  75. #define    W_EXITCODE(ret, sig)    __W_EXITCODE(ret, sig)
  76. #define    W_STOPCODE(sig)        __W_STOPCODE(sig)
  77.  
  78.  
  79. /* Wait for a child to die.  */
  80. extern __pid_t wait (int *);
  81.  
  82. /* Special values for the pid argument to `waitpid' and `wait4'.  */
  83. /* Any process.  */
  84. #define    WAIT_ANY (-1)
  85. /* Any process in my process group.  */
  86. #define    WAIT_MYPGRP 0
  87.  
  88. /* Wait for a child matching PID to die.  */
  89. extern __pid_t waitpid (__pid_t, int *, int);
  90.  
  91. /* Wait for a child to exit.  */
  92. extern __pid_t wait3 (int *, int, struct rusage *);
  93.  
  94. /* Wait for a child matching pid_t to die and return its usage statistics. */
  95. extern __pid_t wait4 (__pid_t, int *, int, struct rusage *);
  96.  
  97. #ifdef __cplusplus
  98.   }
  99. #endif
  100.  
  101. #endif /* sys/wait.h  */
  102.